package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.ysd.entity.Admin;
import com.ysd.util.DBManager;

public class AdminDaoimpl {
	public Admin  getAdminByname(String name) {
		Admin admin=null;
		Connection conn=DBManager.getConnection();
		Statement st=null;
		ResultSet rs=null;
		try {
			st=conn.createStatement();
			rs=st.executeQuery("SELECT * FROM admin where username='"+name+"'");
			while(rs.next()) {
				 admin=new Admin(rs.getInt("userid"), rs.getString("username"), rs.getString("password"));
			}
			return admin;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
